
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue.set()的使用</title>
    <script src="../commonjs/vue.js"></script>
</head>
<body>
    <div id="root">
        <h2>学校名称:{{school.name}}</h2>
        <h2>学校地址:{{school.address}}</h2>
        <h2>校长:{{school.leader}}</h2>
        <button @click="addProp">增加一个属性</button>
    </div>
    <script>
        Vue.config.productionTip = false;//关闭开发提示
        const vm = new Vue({
            el:'#root',
            data:{
                school:{
                    name:'武威职业学院',
                    address:'武威市凉州区'
                }
            },
            methods:{
                addProp(){
                    //Vue.set()
                    Vue.set(this.school,'leader','一个帅气的老师')
                }
            }
        })
    </script>
</body>
</html>